import React, { useState } from "react";
import FormItem from "../../components/Form";
import { timestampToTime } from "../../utils/timestampToTime.js";
export default function Index() {
  const [formLayout] = useState({
    labelCol: { span: 1 },
    wrapperCol: { span: 5 },
  });
  const formItem = [
    {
      type: "Input",
      label: "账号",
      name: "account",
      rule: [
        {
          required: true,
          message: "请输入账号",
        },
      ],
    },
    {
      type: "DatePicker",
      label: "时间",
      name: "datePicker",
      rule: [
        {
          required: true,
          message: "请输入账号",
        },
      ],
      placeholder: "请输入账号",
    },
    {
      type: "Select",
      label: "国家",
      name: "country",
      rule: [
        {
          required: true,
          message: "请选择国家",
        },
      ],
      options: [
        { id: "01", country: "中国", value: "Chian" },
        { id: "02", country: "美国", value: "USA" },
        { id: "03", country: "日本", value: "Japan" },
      ],
      placeholder: "请选择国家",
    },
  ];
  const onFinish = (values) => {
    values.datePicker = values.datePicker.map((item) => {
      return timestampToTime(item);
    });

    console.log(values);
  };
  const [formItemList] = useState(formItem);
  return (
    <FormItem
      formLayout={formLayout}
      formItemList={formItemList}
      onFinish={onFinish}
    />
  );
}
